import type { Metadata } from "next"; import Image from "next/image"; import Link from "next/link"; import { notFound } from "next/navigation"; import { MDXRemote } from "next-mdx-remote/rsc"; import { CalendarDays, Clock, Gauge, ListOrdered, RefreshCw } from "lucide-react"; import remarkGfm from "remark-gfm"; import { mdxComponents, OwnedVideo } from "@/components/mdx/mdx-components"; import { RevealOnScroll } from "@/components/reveal-on-scroll"; import { RecordTutorialView } from "@/components/record-tutorial-view"; import { SaveTutorialButton } from "@/components/save-tutorial-button"; import ShareButton from "@/components/share-button"; import { ReadingProgress } from "@/components/tutorial/reading-progress"; import { InlineTableOfContents, TableOfContents } from "@/components/tutorial/table-of-contents"; import { VideoComingSoon } from "@/components/tutorial/video-coming-soon"; import { DraftBadge, TutorialGrid } from "@/components/tutorial-card"; import { JsonLd } from "@/components/json-ld"; import { AUTHOR, breadcrumbJsonLd, ogImageFor, pageMetadata, tutorialJsonLd } from "@/lib/seo"; import { getTrack } from "@/lib/tracks"; import { getAllTutorials, getTutorial, getTutorialMetas, getTutorialsByTrack, tutorialKey } from "@/lib/tutorials"; import { cn } from "@/lib/utils"; export const dynamicParams = false; export function generateStaticParams() { return getAllTutorials().map((t) => ({ track: t.track, slug: t.slug })); } type Props = { params: Promise<{ track: string; slug: string }> }; export async function generateMetadata({ params }: Props): Promise { const { track, slug } = await params; const tutorial = getTutorial(track, slug); if (!tutorial) return {}; return pageMetadata({ title: tutorial.title, description: tutorial.description, path: `/${tutorial.track}/${tutorial.slug}`, image: ogImageFor(tutorial.cover), type: "article", publishedTime: tutorial.publishedAt || undefined, modifiedTime: tutorial.updatedAt, // Drafts stay out of search results until they're finished noindex: tutorial.draft, }); } const sideHeading = "mb-4 block font-mono text-xs font-medium uppercase tracking-[0.08em]"; const chip = "inline-flex items-center gap-1.5 rounded-full border border-border bg-card px-3 py-1.5 font-mono text-[11px] uppercase tracking-[0.08em] text-[var(--mist)]"; export default async function TutorialPage({ params }: Props) { const { track: trackSlug, slug } = await params; const tutorial = getTutorial(trackSlug, slug); const track = getTrack(trackSlug); if (!tutorial || !track) notFound(); const siblings = getTutorialsByTrack(track.slug); const sections = tutorial.headings.filter((h) => h.depth === 2).length; // Same track first, then the newest from other tracks const more = [ ...siblings.filter((t) => t.slug !== tutorial.slug), ...getTutorialMetas().filter((t) => t.track !== track.slug), ].slice(0, 3); return (
{track.name}

{tutorial.title}

{tutorial.description}

{tutorial.level} {tutorial.minutes} min {tutorial.video ? "watch" : "read"} {sections > 0 && ( {sections} sections )} {tutorial.publishedAt && ( {tutorial.publishedAt} )} {tutorial.updatedAt && tutorial.updatedAt !== tutorial.publishedAt && ( Updated {tutorial.updatedAt} )} {tutorial.draft && }
By {AUTHOR.name}
{tutorial.headings.length > 0 && } {tutorial.video ? ( ) : ( tutorial.videoComingSoon && )}
{tutorial.headings.length > 0 && ( )}
{more.length > 0 && (

Keep going

)}
); }